<?php

//////////////////////////////////////////////////////
// GPAC Database is Copyright 2002 Colin Todd       //
// Written by Colin Todd - All rights reserved.     //
//                                                  //
// colintodd@myfastmail.com                         //
//////////////////////////////////////////////////////

//check user is logged in
include_once('_includes/master_include.php');

$root = './';
include($root . 'include/header.php');
include($root . 'include/dbconnect.php');
$RedirectLocation = $_GET['RedirectLocation'];
$RedirectArgs = @$_GET['RedirectArgs'];
$PHPSESSID = $_GET['PHPSESSID'];
$frmUserId = @$_GET['frmUserId'];

start_div_main();
?>
<font size=+2><b>Delete User</b></font><p>
Not implemented yet<p>
<?php

//echo ;

//exit;
if($PACTS_cfg->getUserIsAdmin() ) {

	if(strlen($frmUserId)>0) {
		$Dusername = getLookValue("Users", "id", $frmUserId, "username");
//		echo "DELETE FROM Users WHERE id=$frmUserId<p>";
//		exit;
		mysql_query("DELETE FROM Users WHERE id=$frmUserId");
//		echo "Record deleted!<br /><br />";
		if(mysql_affected_rows()>0) {
			
			$URLmessage="User has been DELETED sucessfully!";
			$PACTS_cfg->InsertAuditTrailEntry( "", "" ,"Delete","Users","COMPLETE ENTRY",$_SESSION['username'], $_SERVER['PHP_SELF'],$frmUserId."($Dusername)");

		} else {

			$URLmessage="ERROR: Could not DELETE User! : ".mysql_error();

		}
			if(strlen($RedirectLocation)==0) {
				$RedirectLocation = $DefaultRedirectLocation;
			}
			
			$URL = "Location: http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/".$RedirectLocation.".php?";	$URL = $URL."&PHPSESSID=".$PHPSESSID."&URLmessage=$URLmessage";
			if(strlen($RedirectArgs)>0) {
				$URL = $URL."&$RedirectArgs";
			}
			echo "$URL";
			header($URL);
			exit;
	} else {
		echo "Error: Could not delete record!<br /><br />";
	}
}
else {
	echo "<p class=\"errmsg1\">Error! You do not have admin permissions or permission to delete data!</p>";
} // end else $bUserCanDeleteIndicator












//				$PACTS_cfg->InsertAuditTrailEntry("-", $val ,"Edit","Users", $key, $_SESSION['username'], $_SERVER['PHP_SELF'],$frmUserId);
 //


// goto http://oemcomputer/Churts_test/User_edit.php
// url msg :: URLmessage=Family%20details%20updated!

end_div_main();
?> 

<?php
include($root . 'include/footer.php');
?>

